package com.foxnicweb.app.patent.controller;

import java.util.*;
import org.github.foxnic.web.framework.web.SuperController;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import com.github.foxnic.commons.collection.CollectorUtil;
import com.github.foxnic.dao.entity.ReferCause;
import com.github.foxnic.api.swagger.InDoc;
import org.github.foxnic.web.framework.sentinel.SentinelExceptionUtil;
import com.github.foxnic.api.swagger.ApiParamSupport;
import com.alibaba.csp.sentinel.annotation.SentinelResource;


import com.foxnicweb.app.proxy.patent.PatentServiceProxy;
import com.foxnicweb.app.domain.patent.meta.PatentVOMeta;
import com.foxnicweb.app.domain.patent.Patent;
import com.foxnicweb.app.domain.patent.PatentVO;
import com.github.foxnic.api.transter.Result;
import com.github.foxnic.dao.data.SaveMode;
import com.github.foxnic.dao.excel.ExcelWriter;
import com.github.foxnic.springboot.web.DownloadUtil;
import com.github.foxnic.dao.data.PagedList;
import java.util.Date;
import java.sql.Timestamp;
import com.github.foxnic.api.error.ErrorDesc;
import com.github.foxnic.commons.io.StreamUtil;
import java.util.Map;
import com.github.foxnic.dao.excel.ValidateResult;
import java.io.InputStream;
import com.foxnicweb.app.domain.patent.meta.PatentMeta;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiImplicitParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.foxnicweb.app.patent.service.IPatentService;
import com.github.foxnic.api.validate.annotations.NotNull;

/**
 * <p>
 * 专利案接口控制器
 * </p>
 * @author 李方捷 , leefangjie@qq.com
 * @since 2023-04-19 10:25:34
*/

@InDoc
@Api(tags = "专利案")
@RestController("PatPatentController")
public class PatentController extends SuperController {

	@Autowired
	private IPatentService patentService;

	/**
	 * 添加专利案
	*/
	@ApiOperation(value = "添加专利案")
	@ApiImplicitParams({
		@ApiImplicitParam(name = PatentVOMeta.ID , value = "主键" , required = true , dataTypeClass=Long.class , example = "1234776"),
		@ApiImplicitParam(name = PatentVOMeta.SERIAL , value = "案号" , required = false , dataTypeClass=String.class , example = "WSFM-20200038"),
		@ApiImplicitParam(name = PatentVOMeta.TITLE , value = "案件名称" , required = false , dataTypeClass=String.class , example = "一种β-烟酰胺单核苷酸的工艺制备方法"),
		@ApiImplicitParam(name = PatentVOMeta.PROPOSAL_TITLE , value = "提案名称" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CREATION_TIME , value = "⽴案⽇期" , required = false , dataTypeClass=Date.class , example = "2020-06-11 12:00:00"),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_DATE , value = "申请日期" , required = false , dataTypeClass=Date.class),
		@ApiImplicitParam(name = PatentVOMeta.PROJECT_STAGE , value = "案件状态" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.LEVEL , value = "案件等级" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CUSTOMER , value = "客户" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SALES , value = "销售" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.FLOW , value = "流程" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_NUMBER , value = "申请号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SUBTYPE , value = "案件类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AREA , value = "申请国家" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_MANNER , value = "申请方式" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IPR , value = "IPR" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICANTS , value = "申请人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.INVENTORS , value = "发明人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CONTACT , value = "联系人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.PATENT_AGENT , value = "送件代理⼈" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AGENCY , value = "送件代理所" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SERVICE , value = "服务类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.ORDER_SERIAL , value = "订单号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.REMARK , value = "备注" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IS_SUBEXAM_REQUEST , value = "实质审查" , required = false , dataTypeClass=Integer.class),
		@ApiImplicitParam(name = PatentVOMeta.STATUS , value = "状态" , required = false , dataTypeClass=Integer.class , example = "1")
	})
	@ApiParamSupport(ignoreDBTreatyProperties = true, ignoreDefaultVoProperties = true , ignorePrimaryKey = true)
	@ApiOperationSupport(order=1 , author="李方捷 , leefangjie@qq.com")
	@SentinelResource(value = PatentServiceProxy.INSERT , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.INSERT)
	public Result insert(PatentVO patentVO) {

		Result result=patentService.insert(patentVO,false);
		return result;
	}



	/**
	 * 删除专利案
	*/
	@ApiOperation(value = "删除专利案")
	@ApiImplicitParams({
		@ApiImplicitParam(name = PatentVOMeta.ID , value = "主键" , required = true , dataTypeClass=Long.class , example = "1234776")
	})
	@ApiOperationSupport(order=2 , author="李方捷 , leefangjie@qq.com")
	@SentinelResource(value = PatentServiceProxy.DELETE , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.DELETE)
	public Result deleteById(Long id) {

		this.validator().asserts(id).require("缺少id值");
		if(this.validator().failure()) {
			return this.validator().getFirstResult();
		}
		// 引用校验
		ReferCause cause =  patentService.hasRefers(id);
		// 判断是否可以删除
		this.validator().asserts(cause.hasRefer()).requireEqual("不允许删除当前记录："+cause.message(),false);
		if(this.validator().failure()) {
			return this.validator().getFirstResult().messageLevel4Confirm();
		}
		Result result=patentService.deleteByIdPhysical(id);
		return result;
	}


	/**
	 * 批量删除专利案 <br>
	 * 联合主键时，请自行调整实现
	*/
	@ApiOperation(value = "批量删除专利案")
	@ApiImplicitParams({
		@ApiImplicitParam(name = PatentVOMeta.IDS , value = "主键清单" , required = true , dataTypeClass=List.class , example = "[1,3,4]")
	})
	@ApiOperationSupport(order=3 , author="李方捷 , leefangjie@qq.com")
	@SentinelResource(value = PatentServiceProxy.DELETE_BY_IDS , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.DELETE_BY_IDS)
	public Result deleteByIds(List<Long> ids) {

		// 参数校验
		this.validator().asserts(ids).require("缺少ids参数");
		if(this.validator().failure()) {
			return this.validator().getFirstResult();
		}

		// 查询引用
		Map<Long, ReferCause> causeMap = patentService.hasRefers(ids);
		// 收集可以删除的ID值
		List<Long> canDeleteIds = new ArrayList<>();
		for (Map.Entry<Long, ReferCause> e : causeMap.entrySet()) {
			if (!e.getValue().hasRefer()) {
				canDeleteIds.add(e.getKey());
			}
		}

		// 执行删除
		if (canDeleteIds.isEmpty()) {
			// 如果没有一行可以被删除
			return ErrorDesc.failure().message("无法删除您选中的数据行：").data(0)
				.addErrors(CollectorUtil.collectArray(CollectorUtil.filter(causeMap.values(),(e)->{return e.hasRefer();}),ReferCause::message,String.class))
				.messageLevel4Confirm();
		} else if (canDeleteIds.size() == ids.size()) {
			// 如果全部可以删除
			Result result=patentService.deleteByIdsPhysical(canDeleteIds);
			return result;
		} else if (canDeleteIds.size()>0 && canDeleteIds.size() < ids.size()) {
			// 如果部分行可以删除
			Result result=patentService.deleteByIdsPhysical(canDeleteIds);
			if (result.failure()) {
				return result;
			} else {
				return ErrorDesc.success().message("已删除 " + canDeleteIds.size() + " 行，但另有 " + (ids.size() - canDeleteIds.size()) + " 行数据无法删除").data(canDeleteIds.size())
				.addErrors(CollectorUtil.collectArray(CollectorUtil.filter(causeMap.values(),(e)->{return e.hasRefer();}),ReferCause::message,String.class))
				.messageLevel4Confirm();
			}
		} else {
			// 理论上，这个分支不存在
			return ErrorDesc.success().message("数据删除未处理");
		}
	}

	/**
	 * 更新专利案
	*/
	@ApiOperation(value = "更新专利案")
	@ApiImplicitParams({
		@ApiImplicitParam(name = PatentVOMeta.ID , value = "主键" , required = true , dataTypeClass=Long.class , example = "1234776"),
		@ApiImplicitParam(name = PatentVOMeta.SERIAL , value = "案号" , required = false , dataTypeClass=String.class , example = "WSFM-20200038"),
		@ApiImplicitParam(name = PatentVOMeta.TITLE , value = "案件名称" , required = false , dataTypeClass=String.class , example = "一种β-烟酰胺单核苷酸的工艺制备方法"),
		@ApiImplicitParam(name = PatentVOMeta.PROPOSAL_TITLE , value = "提案名称" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CREATION_TIME , value = "⽴案⽇期" , required = false , dataTypeClass=Date.class , example = "2020-06-11 12:00:00"),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_DATE , value = "申请日期" , required = false , dataTypeClass=Date.class),
		@ApiImplicitParam(name = PatentVOMeta.PROJECT_STAGE , value = "案件状态" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.LEVEL , value = "案件等级" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CUSTOMER , value = "客户" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SALES , value = "销售" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.FLOW , value = "流程" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_NUMBER , value = "申请号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SUBTYPE , value = "案件类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AREA , value = "申请国家" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_MANNER , value = "申请方式" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IPR , value = "IPR" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICANTS , value = "申请人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.INVENTORS , value = "发明人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CONTACT , value = "联系人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.PATENT_AGENT , value = "送件代理⼈" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AGENCY , value = "送件代理所" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SERVICE , value = "服务类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.ORDER_SERIAL , value = "订单号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.REMARK , value = "备注" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IS_SUBEXAM_REQUEST , value = "实质审查" , required = false , dataTypeClass=Integer.class),
		@ApiImplicitParam(name = PatentVOMeta.STATUS , value = "状态" , required = false , dataTypeClass=Integer.class , example = "1")
	})
	@ApiParamSupport(ignoreDBTreatyProperties = true, ignoreDefaultVoProperties = true)
	@ApiOperationSupport( order=4 , author="李方捷 , leefangjie@qq.com" ,  ignoreParameters = { PatentVOMeta.PAGE_INDEX , PatentVOMeta.PAGE_SIZE , PatentVOMeta.SEARCH_FIELD , PatentVOMeta.FUZZY_FIELD , PatentVOMeta.SEARCH_VALUE , PatentVOMeta.DIRTY_FIELDS , PatentVOMeta.SORT_FIELD , PatentVOMeta.SORT_TYPE , PatentVOMeta.DATA_ORIGIN , PatentVOMeta.QUERY_LOGIC , PatentVOMeta.REQUEST_ACTION , PatentVOMeta.IDS } )
	@SentinelResource(value = PatentServiceProxy.UPDATE , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.UPDATE)
	public Result update(PatentVO patentVO) {

		Result result=patentService.update(patentVO,SaveMode.DIRTY_OR_NOT_NULL_FIELDS,false);
		return result;
	}


	/**
	 * 保存专利案
	*/
	@ApiOperation(value = "保存专利案")
	@ApiImplicitParams({
		@ApiImplicitParam(name = PatentVOMeta.ID , value = "主键" , required = true , dataTypeClass=Long.class , example = "1234776"),
		@ApiImplicitParam(name = PatentVOMeta.SERIAL , value = "案号" , required = false , dataTypeClass=String.class , example = "WSFM-20200038"),
		@ApiImplicitParam(name = PatentVOMeta.TITLE , value = "案件名称" , required = false , dataTypeClass=String.class , example = "一种β-烟酰胺单核苷酸的工艺制备方法"),
		@ApiImplicitParam(name = PatentVOMeta.PROPOSAL_TITLE , value = "提案名称" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CREATION_TIME , value = "⽴案⽇期" , required = false , dataTypeClass=Date.class , example = "2020-06-11 12:00:00"),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_DATE , value = "申请日期" , required = false , dataTypeClass=Date.class),
		@ApiImplicitParam(name = PatentVOMeta.PROJECT_STAGE , value = "案件状态" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.LEVEL , value = "案件等级" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CUSTOMER , value = "客户" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SALES , value = "销售" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.FLOW , value = "流程" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_NUMBER , value = "申请号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SUBTYPE , value = "案件类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AREA , value = "申请国家" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_MANNER , value = "申请方式" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IPR , value = "IPR" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICANTS , value = "申请人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.INVENTORS , value = "发明人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CONTACT , value = "联系人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.PATENT_AGENT , value = "送件代理⼈" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AGENCY , value = "送件代理所" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SERVICE , value = "服务类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.ORDER_SERIAL , value = "订单号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.REMARK , value = "备注" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IS_SUBEXAM_REQUEST , value = "实质审查" , required = false , dataTypeClass=Integer.class),
		@ApiImplicitParam(name = PatentVOMeta.STATUS , value = "状态" , required = false , dataTypeClass=Integer.class , example = "1")
	})
	@ApiParamSupport(ignoreDBTreatyProperties = true, ignoreDefaultVoProperties = true)
	@ApiOperationSupport(order=5 ,  ignoreParameters = { PatentVOMeta.PAGE_INDEX , PatentVOMeta.PAGE_SIZE , PatentVOMeta.SEARCH_FIELD , PatentVOMeta.FUZZY_FIELD , PatentVOMeta.SEARCH_VALUE , PatentVOMeta.DIRTY_FIELDS , PatentVOMeta.SORT_FIELD , PatentVOMeta.SORT_TYPE , PatentVOMeta.DATA_ORIGIN , PatentVOMeta.QUERY_LOGIC , PatentVOMeta.REQUEST_ACTION , PatentVOMeta.IDS } )
	@SentinelResource(value = PatentServiceProxy.SAVE , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.SAVE)
	public Result save(PatentVO patentVO) {

		Result result=patentService.save(patentVO,SaveMode.DIRTY_OR_NOT_NULL_FIELDS,false);
		return result;
	}


	/**
	 * 获取专利案
	*/
	@ApiOperation(value = "获取专利案")
	@ApiImplicitParams({
		@ApiImplicitParam(name = PatentVOMeta.ID , value = "主键" , required = true , dataTypeClass=Long.class , example = "1"),
	})
	@ApiOperationSupport(order=6 , author="李方捷 , leefangjie@qq.com")
	@SentinelResource(value = PatentServiceProxy.GET_BY_ID , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.GET_BY_ID)
	public Result<Patent> getById(Long id) {

		Result<Patent> result=new Result<>();
		Patent patent=patentService.getById(id);
		result.success(true).data(patent);
		return result;
	}


	/**
	 * 批量获取专利案 <br>
	 * 联合主键时，请自行调整实现
	*/
		@ApiOperation(value = "批量获取专利案")
		@ApiImplicitParams({
				@ApiImplicitParam(name = PatentVOMeta.IDS , value = "主键清单" , required = true , dataTypeClass=List.class , example = "[1,3,4]")
		})
		@ApiOperationSupport(order=3 , author="李方捷 , leefangjie@qq.com")
		@SentinelResource(value = PatentServiceProxy.GET_BY_IDS , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.GET_BY_IDS)
	public Result<List<Patent>> getByIds(List<Long> ids) {

		Result<List<Patent>> result=new Result<>();
		List<Patent> list=patentService.queryListByIds(ids);
		result.success(true).data(list);
		return result;
	}


	/**
	 * 查询专利案
	*/
	@ApiOperation(value = "查询专利案")
	@ApiImplicitParams({
		@ApiImplicitParam(name = PatentVOMeta.ID , value = "主键" , required = true , dataTypeClass=Long.class , example = "1234776"),
		@ApiImplicitParam(name = PatentVOMeta.SERIAL , value = "案号" , required = false , dataTypeClass=String.class , example = "WSFM-20200038"),
		@ApiImplicitParam(name = PatentVOMeta.TITLE , value = "案件名称" , required = false , dataTypeClass=String.class , example = "一种β-烟酰胺单核苷酸的工艺制备方法"),
		@ApiImplicitParam(name = PatentVOMeta.PROPOSAL_TITLE , value = "提案名称" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CREATION_TIME , value = "⽴案⽇期" , required = false , dataTypeClass=Date.class , example = "2020-06-11 12:00:00"),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_DATE , value = "申请日期" , required = false , dataTypeClass=Date.class),
		@ApiImplicitParam(name = PatentVOMeta.PROJECT_STAGE , value = "案件状态" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.LEVEL , value = "案件等级" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CUSTOMER , value = "客户" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SALES , value = "销售" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.FLOW , value = "流程" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_NUMBER , value = "申请号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SUBTYPE , value = "案件类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AREA , value = "申请国家" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_MANNER , value = "申请方式" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IPR , value = "IPR" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICANTS , value = "申请人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.INVENTORS , value = "发明人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CONTACT , value = "联系人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.PATENT_AGENT , value = "送件代理⼈" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AGENCY , value = "送件代理所" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SERVICE , value = "服务类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.ORDER_SERIAL , value = "订单号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.REMARK , value = "备注" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IS_SUBEXAM_REQUEST , value = "实质审查" , required = false , dataTypeClass=Integer.class),
		@ApiImplicitParam(name = PatentVOMeta.STATUS , value = "状态" , required = false , dataTypeClass=Integer.class , example = "1")
	})
	@ApiOperationSupport(order=5 , author="李方捷 , leefangjie@qq.com" ,  ignoreParameters = { PatentVOMeta.PAGE_INDEX , PatentVOMeta.PAGE_SIZE } )
	@SentinelResource(value = PatentServiceProxy.QUERY_LIST , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.QUERY_LIST)
	public Result<List<Patent>> queryList(PatentVO sample) {

		Result<List<Patent>> result=new Result<>();
		List<Patent> list=patentService.queryList(sample);
		result.success(true).data(list);
		return result;
	}


	/**
	 * 分页查询专利案
	*/
	@ApiOperation(value = "分页查询专利案")
	@ApiImplicitParams({
		@ApiImplicitParam(name = PatentVOMeta.ID , value = "主键" , required = true , dataTypeClass=Long.class , example = "1234776"),
		@ApiImplicitParam(name = PatentVOMeta.SERIAL , value = "案号" , required = false , dataTypeClass=String.class , example = "WSFM-20200038"),
		@ApiImplicitParam(name = PatentVOMeta.TITLE , value = "案件名称" , required = false , dataTypeClass=String.class , example = "一种β-烟酰胺单核苷酸的工艺制备方法"),
		@ApiImplicitParam(name = PatentVOMeta.PROPOSAL_TITLE , value = "提案名称" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CREATION_TIME , value = "⽴案⽇期" , required = false , dataTypeClass=Date.class , example = "2020-06-11 12:00:00"),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_DATE , value = "申请日期" , required = false , dataTypeClass=Date.class),
		@ApiImplicitParam(name = PatentVOMeta.PROJECT_STAGE , value = "案件状态" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.LEVEL , value = "案件等级" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CUSTOMER , value = "客户" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SALES , value = "销售" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.FLOW , value = "流程" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_NUMBER , value = "申请号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SUBTYPE , value = "案件类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AREA , value = "申请国家" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICATION_MANNER , value = "申请方式" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IPR , value = "IPR" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.APPLICANTS , value = "申请人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.INVENTORS , value = "发明人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.CONTACT , value = "联系人" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.PATENT_AGENT , value = "送件代理⼈" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.AGENCY , value = "送件代理所" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.SERVICE , value = "服务类型" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.ORDER_SERIAL , value = "订单号" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.REMARK , value = "备注" , required = false , dataTypeClass=String.class),
		@ApiImplicitParam(name = PatentVOMeta.IS_SUBEXAM_REQUEST , value = "实质审查" , required = false , dataTypeClass=Integer.class),
		@ApiImplicitParam(name = PatentVOMeta.STATUS , value = "状态" , required = false , dataTypeClass=Integer.class , example = "1")
	})
	@ApiOperationSupport(order=8 , author="李方捷 , leefangjie@qq.com")
	@SentinelResource(value = PatentServiceProxy.QUERY_PAGED_LIST , blockHandlerClass = { SentinelExceptionUtil.class } , blockHandler = SentinelExceptionUtil.HANDLER )
	@PostMapping(PatentServiceProxy.QUERY_PAGED_LIST)
	public Result<PagedList<Patent>> queryPagedList(PatentVO sample) {

		Result<PagedList<Patent>> result=new Result<>();
		PagedList<Patent> list=patentService.queryPagedList(sample,sample.getPageSize(),sample.getPageIndex());
		result.success(true).data(list);
		return result;
	}





}
